< previous page page_602 next page >

Page 602
e10a6a0a59f035e870d90cca05b85fce.gif
(x - px) * nx + (y - py) * ny + (z - pz) * nz = 0
You can rewrite this equation as:
A* x + B * y + C * z + D = 0
where
e10a6a0a59f035e870d90cca05b85fce.gif
A = nx
B = ny
C = nz
D = - (nx * px + ny * py + nz * pz)
Now suppose you want to find the intersection between this plane and a ray passing through the point C = (cx, cy, cz) in the direction of the vector V = <vx, vy, vz>. You can represent the ray using parametric equations like this:
e10a6a0a59f035e870d90cca05b85fce.gif
X(t) = cx + t * vx
Y(t) = cy + t * vy
Z(t) = cz + t * vz
Substituting these values into the plane equation you get:
e10a6a0a59f035e870d90cca05b85fce.gif
A * (cx + t * vx) + B * (cy + t * vy) + C * (cz + t * vz) + D = 0
Solving this equation for t gives:
e10a6a0a59f035e870d90cca05b85fce.gif
t * (A * vx + B * vy + C * vz) + A * cx + B * cy + C * cz + D = 0
t = -(A * cx + B * cy + C * cz + D) / (A * vx + B * vy + C * vz)
If the denominator (A * vx + B * vy + C * vz) equals zero, the ray is parallel to the plane and does not intersect it. Otherwise, the equation gives the value for t at the intersection.
If t < 0, the ray intersects the plane behind the point at which the ray originates, so the intersection is not interesting to a ray tracing program. Otherwise you can insert the value of t into the parametric equations for the ray to determine the exact point of intersection.
Because you will need to transform the plane, you should store the information that generates the plane in a way that allows you to transform it. For instance, you could store the coordinates of a point on the plane and the components of the plane's normal vector. You can rotate the plane by applying the rotation to the point and vector. Unfortunately, translations do not work properly for the vector. If you translated the vector's components by 1 unit in the X direction, for example, you would change the vector's direction and length. This would distort the vector and change the orientation of the plane.
A better solution is to store the coordinates of a point on the plane and the coordinates of a point that lies along the normal vector placed at that point. If the point on the plane is (px, py, pz) and the normal vector has components <vx, vy, vz>, the second point you should store is P2 = (px + nx, py + ny, pz + nz). To transform the plane, you can now

 
< previous page page_602 next page >